package com.sweets.look.ui.setting;

import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import java.io.File;

import com.bilibili.magicasakura.utils.ThemeUtils;
import com.bilibili.magicasakura.widgets.TintToolbar;
import com.sweet.satellite.GlobalConfig;
import com.sweet.satellite.TranslucentSBActivity;
import com.sweets.look.R;
import com.sweets.look.constant.Constants;
import com.sweets.look.preference.PreferenceManager;
import com.sweets.look.ui.activity.MainActivity;
import com.sweets.look.ui.view.CardPickerDialog;
import com.sweets.look.ui.widget.MarkDialog;
import com.sweets.look.ui.widget.MarkEditDialog;
import com.sweets.look.ui.widget.MarkEditDialog.OnCustomDialogListener;
import com.sweets.look.ui.widget.MarkRadioDialog;
import com.sweets.look.util.BrowserUtils;
import com.sweets.look.util.FileUtils;
import com.sweets.look.util.ThemeHelper;
import com.sweets.look.util.Utils;
import com.sweets.look.util.ViewHelper;
import com.sweets.look.util.ViewUtils;

public class GeneralSettings extends TranslucentSBActivity implements CardPickerDialog.ClickListener {
    private Activity mActivity;
    private TextView mAgentTextView;
    private CheckBox mCbAdBlock;
    private CheckBox mCbFlash;
    private CheckBox mCbFullscreen;
    private Context mContext;
    private TextView mDownloadTextView;
    private String mHomepage;
    private int mHomepageChoice;
    private TextView mHomepageText;
    private PreferenceManager mPreferences;
    private TextView mSearchText;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.settings_general);
        this.setToolbarTitle(R.string.settings);

        this.mContext = this;
        this.mActivity = this;
        this.initTextView();
        this.initFullscreenPreference();
        this.initFlashPreference();
        this.initAdBlockPreference();
        ViewUtils.swipeToFinish(this.findViewById(R.id.settingLayout), this);


        RelativeLayout layoutUIMode = (RelativeLayout) findViewById(R.id.layoutUIMode);
        layoutUIMode.setVisibility(View.GONE);
        RelativeLayout layoutUserAgent = (RelativeLayout) findViewById(R.id.layoutUserAgent);
        layoutUserAgent.setVisibility(View.GONE);

        RelativeLayout layoutHomepage = (RelativeLayout) findViewById(R.id.layoutHomepage);
        layoutHomepage.setVisibility(View.GONE);

        LinearLayout layout_ad_block = (LinearLayout) findViewById(R.id.layout_ad_block);
        layout_ad_block.setVisibility(View.GONE);

        TextView layoutAddonsSettings = (TextView) findViewById(R.id.layoutAddonsSettings);
        layoutAddonsSettings.setVisibility(View.GONE);


    }


    /**
     *
     */
    private void agentPicker() {
        new MarkEditDialog(this.mActivity).builder()
                .setTitle(this.getResources().getString(R.string.title_user_agent))
                .setCanceledOnTouchOutside(true)
                .setTitleHint("", this.mPreferences.getUserAgentString(
                        "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36"))
                .setPositiveButton(this.getResources().getString(R.string.action_ok), new OnCustomDialogListener
                        () {
                    @Override
                    public void back(String title, String msg, String other) {
                        mPreferences.setUserAgentChoice(6);
                        mAgentTextView.setText(getResources().getString(R.string.agent_custom));
                        mPreferences.setUserAgentString(title);
                        mAgentTextView.setText(getResources().getString(R.string.agent_custom));
                    }
                }).show();
    }

    private void agentPreference() {
        new MarkRadioDialog(this).builder()
                .setTitle(this.getResources().getString(R.string.title_user_agent))
                .setCancelable(true)
                .setSingleChoiceItems(R.array.array_user_agent, this.mPreferences.getUserAgentChoice()
                        - 1, new RadioGroup.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(RadioGroup group, int checkedId) {
                        if (checkedId == 5) {//5
                            agentPicker();
                        } else {
                            mPreferences.setUserAgentChoice(checkedId + 1);
                            initTextView();
                        }
                    }
                }).show();
    }

    private void downPicker() {
        new MarkEditDialog(((Context) this)).builder().setTitle(Constants.EXTERNAL_STORAGE + '/').setCanceledOnTouchOutside(
                true).setTitleHint("", this.mPreferences.getDownloadDirectory()).setPositiveButton(this
                .getResources().getString(R.string.action_ok), new OnCustomDialogListener() {
            public void back(String title, String msg, String other) {
                GeneralSettings.this.mPreferences.setDownloadDirectory(title);
                GeneralSettings.this.mDownloadTextView.setText(GeneralSettings.this.getString(R.string.download_location,
                        new Object[]{Constants.EXTERNAL_STORAGE, title}));
            }
        }).show();
    }

    private void getFlashChoice() {
        new MarkDialog(this.mActivity).builder().setTitle(this.mContext.getResources().getString(R.string.title_flash))
                .setMessage(this.getResources().getString(R.string.flash)).setCancelable(true).setPositiveButton(
                this.getResources().getString(R.string.action_manual), new View.OnClickListener() {
                    public void onClick(View v) {
                        GeneralSettings.this.mPreferences.setFlashSupport(1);
                    }
                }).setNeutralButton(this.getResources().getString(R.string.action_auto), new View.OnClickListener() {
            public void onClick(View v) {
                GeneralSettings.this.mPreferences.setFlashSupport(2);
            }
        }).setNegativeButton(this.getResources().getString(R.string.action_no), new View.OnClickListener() {
            public void onClick(View v) {
                GeneralSettings.this.mPreferences.setFlashSupport(0);
            }
        }).show();
    }


    private void homepagePreference() {
        new MarkRadioDialog(this).builder()
                .setTitle(this.getResources().getString(R.string.home))
                .setCancelable(true).setSingleChoiceItems(R.array.array_homepage,
                this.mHomepageChoice, new RadioGroup.OnCheckedChangeListener
                        () {
                    public void onCheckedChanged(RadioGroup group, int checkedId) {
                        switch (checkedId) {
                            case 0: {
                                mPreferences.setHomepage("about:home");
                                break;
                            }
                            case 1: {
                                mPreferences.setHomepage("about:blank");
                                break;
                            }
                            case 2: {
                                mPreferences.setHomepage("about:bookmarks");
                                break;
                            }
                            case 3: {
                                break;
                            }
                            case 4: {
                                mPreferences.setHomepage("about:links");
                                break;
                            }
                        }

                        initTextView();
                    }
                }).show();
    }

    /**
     *
     */
    private void initAdBlockPreference() {
        this.mCbAdBlock = (CheckBox) this.findViewById(R.id.cbAdBlock);
        this.mCbAdBlock.setChecked(mPreferences.getAdBlockEnabled());
        this.mCbAdBlock.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mPreferences.setAdBlockEnabled(isChecked);
                if (mPreferences.getAdBlockEnabled()) {
                    new MarkDialog(mContext).builder().setTitle(
                            getResources().getString(R.string.block_ads))
                            .setCancelable(false)
                            .setMessage(getResources().getString(R.string.dialog_adblock))
                            .setPositiveButton(getResources().getString(R.string.dialog_adblock_custom),
                                    new View.OnClickListener() {//强力拦截
                                        @Override
                                        public void onClick(View v) {
                                            mPreferences.setLocalAdBlockEnabled(false);
                                            localHosts();//hosts拦截
                                        }
                                    })
                            .setNegativeButton(getResources().getString(R.string.dialog_adblock_default),
                                    new View.OnClickListener() {//默认拦截
                                        @Override
                                        public void onClick(View v) {
                                            mPreferences.setLocalAdBlockEnabled(true);
                                        }
                                    }).show();
                }
            }
        });
    }

    /**
     *
     */
    private void initFlashPreference() {
        if (Build.VERSION.SDK_INT >= 19) {
            this.findViewById(R.id.layoutFlash).setVisibility(View.GONE);
            return;
        }

        this.mCbFlash = (CheckBox) this.findViewById(R.id.cbFlash);
        if (this.mPreferences.getFlashSupport() > 0) {
            this.mCbFlash.setChecked(true);
        } else {
            this.mCbFlash.setChecked(false);
        }

        mCbFlash.setEnabled(Build.VERSION.SDK_INT < 19);
        this.mCbFlash.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

                if (isChecked) {
                    GeneralSettings.this.getFlashChoice();
                } else {
                    GeneralSettings.this.mPreferences.setFlashSupport(0);
                }

                int v2 = 0;
                try {
                    if (GeneralSettings.this.getPackageManager().getApplicationInfo("com.adobe.flashplayer", 0) == null) {
                    } else {
                        v2 = 1;
                    }
                } catch (PackageManager.NameNotFoundException e) {
                    v2 = 0;
                }
                if (v2 == 0 && (isChecked)) {
                    ViewUtils.createInformativeDialog(GeneralSettings.this, GeneralSettings.this.getResources()
                            .getString(R.string.title_warning), GeneralSettings.this.getResources().getString(R.string.dialog_adobe_not_installed));
                    buttonView.setChecked(false);
                    mPreferences.setFlashSupport(0);
                } else if (Constants.API >= 17 && (isChecked)) {
                    ViewUtils.createInformativeDialog(GeneralSettings.this, getResources().getString(R.string.title_warning),
                            getResources().getString(R.string.dialog_adobe_unsupported));
                }
            }
        });
    }

    private void initFullscreenPreference() {
        this.mCbFullscreen = (CheckBox) this.findViewById(R.id.cbFullscreen);
        this.mCbFullscreen.setChecked(this.mPreferences.getFullScreenEnabled());
        this.mCbFullscreen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mPreferences.setFullScreenEnabled(isChecked);
            }
        });
    }

    private void initTextView() {
        this.mPreferences = PreferenceManager.getInstance();
        this.mSearchText = (TextView) this.findViewById(R.id.searchText);

        switch (this.mPreferences.getSearchChoice()) {
            case 0: {
                this.mSearchText.setText(this.getResources().getString(R.string.custom_url));
                break;
            }
            case 1: {
                this.mSearchText.setText(this.getResources().getString(R.string.baidu_url));
                break;
            }
            case 2: {
                this.mSearchText.setText(this.getResources().getString(R.string.google_url));
                break;
            }
            case 3: {
                this.mSearchText.setText(this.getResources().getString(R.string.bing_url));
                break;
            }
            case 4: {
                this.mSearchText.setText(this.getResources().getString(R.string.shenma_url));
                break;
            }
            case 5: {
                this.mSearchText.setText(this.getResources().getString(R.string.haosou_url));
                break;
            }
        }
        TextView renderText = (TextView) this.findViewById(R.id.renderText);
        switch (this.mPreferences.getRenderingMode()) {
            case 0: {
                renderText.setText(this.mContext.getString(R.string.name_normal));
                break;
            }
            case 1: {
                renderText.setText(this.mContext.getString(R.string.name_inverted));
                break;
            }
            case 2: {
                renderText.setText(this.mContext.getString(R.string.name_grayscale));
                break;
            }
            case 3: {
                renderText.setText(this.mContext.getString(R.string.name_inverted_grayscale));
                break;
            }
        }

        this.mAgentTextView = (TextView) this.findViewById(R.id.agentText);
        this.mHomepageText = (TextView) this.findViewById(R.id.homepageText);
        this.mDownloadTextView = (TextView) this.findViewById(R.id.downloadText);
        if (Constants.API >= 19) {
            this.mPreferences.setFlashSupport(0);
        }

        this.mHomepage = this.mPreferences.getHomepage();
        this.mDownloadTextView.setText(Utils.getDownloadPath());
        if (this.mHomepage.contains("about:home")) {
            this.mHomepageText.setText(this.getResources().getString(R.string.action_homepage));
            this.mHomepageChoice = 0;
        } else if (this.mHomepage.contains("about:blank")) {
            this.mHomepageText.setText(this.getResources().getString(R.string.action_blank));
            this.mHomepageChoice = 1;
        } else if (this.mHomepage.contains("about:bookmarks")) {
            this.mHomepageText.setText(this.getResources().getString(R.string.action_bookmarks));
            this.mHomepageChoice = 2;
        } else if (this.mHomepage.contains("about:links")) {
            this.mHomepageText.setText(this.getResources().getString(R.string.action_link));
            this.mHomepageChoice = 4;
        } else {
            this.mHomepageText.setText(this.mHomepage);
            this.mHomepageChoice = 3;
        }

        switch (mPreferences.getUserAgentChoice()) {
            case 1: {
                this.mAgentTextView.setText(this.getResources().getString(R.string.agent_default));
                break;
            }
            case 2: {
                this.mAgentTextView.setText(this.getResources().getString(R.string.agent_chrome));
                break;
            }
            case 3: {
                this.mAgentTextView.setText(this.getResources().getString(R.string.agent_ie));
                break;
            }
            case 4: {
                this.mAgentTextView.setText(this.getResources().getString(R.string.agent_iphone));
                break;
            }
            case 5: {
                this.mAgentTextView.setText(this.getResources().getString(R.string.agent_symbian));
                break;
            }
            case 6: {
                this.mAgentTextView.setText(this.getResources().getString(R.string.agent_custom));
                break;
            }
        }
        TextView orientationText = (TextView) this.findViewById(R.id.orientationText);
        switch (mPreferences.getScreenOrientation()) {
            case 1: {
                orientationText.setText(this.getResources().getString(R.string.orientation_system));
                break;
            }
            case 2: {
                orientationText.setText(this.getResources().getString(R.string.orientation_auto));
                break;
            }
            case 3: {
                orientationText.setText(this.getResources().getString(R.string.orientation_portrait));
                break;
            }
            case 4: {
                orientationText.setText(this.getResources().getString(R.string.orientation_landscape));
                break;
            }
        }

        TextView uiText = (TextView) this.findViewById(R.id.uiText);
        switch (this.mPreferences.getUIChoice()) {
            case 0: {
                uiText.setText(this.getResources().getString(R.string.ui_auto));
                break;
            }
            case 1: {
                uiText.setText(this.getResources().getString(R.string.ui_phone));
                break;
            }
            case 2: {
                uiText.setText(this.getResources().getString(R.string.ui_tablet));
                break;
            }
        }
    }

    /**
     * 广告拦截hosts
     */
    private void localHosts() {
        String v9 = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) +
                "/hosts.txt";
        if (!FileUtils.fileIsExists(new File(Environment.getExternalStoragePublicDirectory(Environment
                .DIRECTORY_DOWNLOADS), "hosts.txt"))) {//下载文件
            BrowserUtils.downloadFile(this.mActivity,
                    "http://Lakor.opendrive.com/files/OTBfMzU5MTI2X1I5TnVWXzRmNjM/hosts.txt",
                    "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36",
                    "attachment",
                    null,
                    false,
                    "hosts.txt",
                    false);
            ViewUtils.createInformativeDialog(this.mContext, this.getResources().getString(R.string.block_ads),
                    getResources().getString(R.string.dialog_adblock_download) + v9 + this.getResources().getString(R.string.dialog_adblock_custom_hint));
        } else {
            ViewUtils.createInformativeDialog(this.mContext, this.getResources().getString(R.string.block_ads), v9 +
                    getResources().getString(R.string.dialog_adblock_custom_hint));
        }
    }


    /**
     * @param v
     */
    public void onSettingsItemClick(View v) {

        boolean v0 = true;
        switch (v.getId()) {
            case R.id.layoutFullscreen: {//自动隐藏操作栏
                if (this.mCbFullscreen.isChecked()) {
                    v0 = false;
                }

                mCbFullscreen.setChecked(v0);
                break;
            }
            case R.id.layoutFlash: {//启用Flash
                if (this.mCbFlash.isChecked()) {
                    v0 = false;
                }

                mCbFlash.setChecked(v0);
                break;
            }
            case R.id.layoutUIMode: {//应用布局
                this.uiPreference();
                break;
            }
            case R.id.layoutUserAgent: {//浏览器标识
                this.agentPreference();
                break;
            }
            case R.id.layoutScreenOrientation: {//屏幕方向
                this.orientationPreference();
                break;
            }
            case R.id.layoutDownload: {//下载目录
                this.downPicker();
                break;
            }
            case R.id.layoutHomepage: {//主页
                this.homepagePreference();
                break;
            }
            case R.id.layoutSearch: {//搜索引擎
                this.searchPreference();
                break;
            }
            case R.id.layoutRendering: {//渲染模式
                this.renderPicker();
                break;
            }
            case R.id.layoutDefault: {//设置默认浏览器
                this.setDefaultBrowser();
                break;
            }
            case R.id.layoutAdBlock: {//广告拦截
                if (this.mCbAdBlock.isChecked()) {
                    v0 = false;
                }

                mCbAdBlock.setChecked(v0);
                break;
            }
            case R.id.layoutBlockSettings: {//广告标记
                this.startActivity(new Intent(this.mContext, BlockSettings.class));
                break;
            }
            case R.id.layoutAddonsSettings: {//插件

                break;
            }
            case R.id.layoutOperationSettings: {//操作
                this.startActivity(new Intent(this.mContext, OperationSettings.class));
                break;
            }
            case R.id.layoutBookmarkSettings: {//书签
                this.startActivity(new Intent(this.mContext, BookmarkSettings.class));
                break;
            }
            case R.id.layoutDisplaySettings: {//浏览
                this.startActivity(new Intent(this.mContext, DisplaySettings.class));
                break;
            }
            case R.id.layoutPrivacySettings: {//隐私
                this.startActivity(new Intent(this.mContext, PrivacySettings.class));
                break;
            }
            case R.id.layoutAdvancedSettings: {//高级
                this.startActivity(new Intent(this.mContext, AdvancedSettings.class));
                break;
            }
            case R.id.layoutAboutSettings: {//关于
                this.startActivity(new Intent(this.mContext, AboutSettings.class));
                break;
            }
            case R.id.layoutThemeSettings: {
                if (mPreferences == null) {
                    mPreferences = PreferenceManager.getInstance();
                }
                if (mPreferences.getNightModeEnabled()) {
                    ViewUtils.showToast(findViewById(R.id.settingLayout), "白天模式下才能选择主题哦");
                    return;
                }

                CardPickerDialog dialog = new CardPickerDialog();
                dialog.setClickListener(this);
                dialog.show(getSupportFragmentManager(), CardPickerDialog.TAG);
                break;
            }
        }
    }

    private void orientationPreference() {
        new MarkRadioDialog(((Context) this)).builder().setTitle(this.getResources().getString(R.string.orientation))
                .setCancelable(true).setSingleChoiceItems(R.array.array_screen_orientation,
                this.mPreferences.getScreenOrientation()
                        - 1, new RadioGroup.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(RadioGroup group, int checkedId) {
                        GeneralSettings.this.mPreferences.setScreenOrientation(checkedId + 1);
                        GeneralSettings.this.initTextView();
                    }
                }).show();
    }

    private void renderPicker() {
        new MarkRadioDialog(((Context) this)).builder().setTitle(this.getResources().getString(R.string.rendering_mode))
                .setCancelable(true).setSingleChoiceItems(R.array.array_rendering_mode,
                this.mPreferences.getRenderingMode(),
                new RadioGroup.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(RadioGroup group, int checkedId) {
                        GeneralSettings.this.mPreferences.setRenderingMode(checkedId);
                        GeneralSettings.this.initTextView();
                    }
                }).show();
    }

    private void searchPreference() {
        new MarkRadioDialog(((Context) this)).builder().setTitle(this.getResources().getString(R.string.title_search_engine))
                .setCancelable(true).setSingleChoiceItems(R.array.array_search_engine,
                this.mPreferences.getSearchChoice(),
                new RadioGroup.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(RadioGroup group, int checkedId) {
                        if (checkedId == 0) {
                            GeneralSettings.this.searchUrlPicker();
                        } else {
                            GeneralSettings.this.mPreferences.setSearchChoice(checkedId);
                            GeneralSettings.this.initTextView();
                        }
                    }
                }).show();
    }

    private void searchUrlPicker() {
        new MarkEditDialog(((Context) this)).builder().setTitle(this.getResources().getString(R.string.custom_url))
                .setCanceledOnTouchOutside(true).setTitleHint("", this.mPreferences.getSearchUrl()).
                setPositiveButton(this.getResources().getString(R.string.action_ok), new OnCustomDialogListener
                        () {
                    @Override
                    public void back(String url, String msg, String other) {
                        GeneralSettings.this.mPreferences.setSearchChoice(0);
                        GeneralSettings.this.mSearchText.setText(GeneralSettings.this.getResources().getString(
                                R.string.custom_url));
                        GeneralSettings.this.mPreferences.setSearchUrl(BrowserUtils.fixUrl(url));
                        GeneralSettings.this.mSearchText.setText(GeneralSettings.this.getResources().getString(
                                R.string.custom_url));
                    }
                }).show();
    }

    private void setDefaultBrowser() {
        Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("http://www.jianshu.com"));
        PackageManager pm = this.mContext.getPackageManager();
        String origin = pm.resolveActivity(intent, 0).activityInfo.packageName;
        if (origin.equalsIgnoreCase("android")) {
            this.startActivity(intent);
        } else if (origin.equalsIgnoreCase(Utils.getAppPackageName(this.mContext))) {
            pm.clearPackagePreferredActivities(this.mContext.getPackageName());
            this.startActivity(intent);
        } else {
            this.startActivity(new Intent("android.settings.APPLICATION_DETAILS_SETTINGS", Uri.parse(
                    "package:" + origin)));
            ViewUtils.showToast(findViewById(R.id.settingLayout), this.getResources().getString(R.string.toast_clear_defaults));
        }
    }

    private void uiPreference() {
        new MarkRadioDialog(this).builder().setTitle(this.getResources().getString(R.string.ui_mode))
                .setCancelable(true).setSingleChoiceItems(R.array.array_ui_mode, this.mPreferences.getUIChoice(),
                new RadioGroup.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(RadioGroup group, int checkedId) {
                        GeneralSettings.this.mPreferences.setUIChoice(checkedId);
                        GeneralSettings.this.initTextView();
                    }
                }).show();
    }

    @Override
    public void onConfirm(int currentTheme) {
        if (ThemeHelper.getTheme(GeneralSettings.this) != currentTheme) {
            ThemeHelper.setLastTheme(GeneralSettings.this, currentTheme);
            ThemeHelper.setTheme(GeneralSettings.this, currentTheme);
            ThemeUtils.refreshUI(GeneralSettings.this, new ThemeUtils.ExtraRefreshable() {
                        @Override
                        public void refreshGlobal(Activity activity) {
                            //for global setting, just do once
                            if (Build.VERSION.SDK_INT >= 21) {
                                final GeneralSettings context = GeneralSettings.this;
                                ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(null, null, ThemeUtils.getThemeAttrColor(context, android.R.attr.colorPrimary));
                                setTaskDescription(taskDescription);
                                getWindow().setStatusBarColor(ThemeUtils.getColorById(context, R.color.theme_color_primary));
                            }

                            ViewHelper.setStatusBarTintColor(GeneralSettings.this, ThemeUtils.getColorById(GeneralSettings.this, R.color.theme_color_primary));
                            sendBroadcast(new Intent(MainActivity.ACTION));
                        }

                        @Override
                        public void refreshSpecificView(View view) {
                            //TODO: will do this for each traversal
                        }
                    }
            );
        }
    }
}

